package org.example.testautowire;


import java.util.stream.Stream;

public class TestMain {

    public static void main(String[] args) {
        BController bController = new BController();
        Bservice bservice = new Bservice();
        Class<? extends BController> bClass = bController.getClass();
        Stream.of(bClass.getDeclaredFields()).forEach(f ->{
            Xautowire annotation = f.getAnnotation(Xautowire.class);
            if(annotation != null){
                f.setAccessible(true);
                Class<?> typeClass = f.getType();
                try {
                    Object o = typeClass.newInstance();
                    f.set(bController,o);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });

        bController.doService();
    }
}
